#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 110;

int t;
int n, l;
ll a[N];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> t;
    while (t--) {
        cin >> n >> l;
        for (int i = 0;i < n;i++) cin >> a[i];

        int ans = 0;
        for (int i = 0; i < l; i++) {
            int cnt = 0;
            int mask = 1 << i;
            for (int j = 0; j < n; j++) {
                if (a[j] & mask) cnt++;
            }
            if (cnt * 2 >= n) ans |= mask;
        }
        cout << ans << endl;
    }
    return 0;
}